#include <iostream>
#include <cstdlib>
#include <ctime>
#include <chrono>
#include "mergeSort.hpp"

using namespace std;
using namespace chrono;
void setRandomArray(vector<int>& nums, int size, int min, int max)
{
    for(int i = 0; i < size; i++)
    {
        nums.push_back(rand() % (max - min + 1) + min);
    }
}
void printArray(vector<int>& nums)
{
    for(int num : nums) cout << num << " ";
    cout << endl;
}

void testSortEfficiency(int size, int min, int max)
{
    vector<int> nums;
    setRandomArray(nums, size, min, max);
    auto start = chrono::steady_clock::now();
    mergeSort(nums, 0, nums.size() - 1);
    auto end = chrono::steady_clock::now();
    auto duration = chrono::duration_cast<milliseconds>(end - start);
    cout << "sort time: " << duration.count() << "ms" << endl;
}

int main()
{
    srand(time(nullptr));
    testSortEfficiency(10000000, 0, 100000000); // 用一千万个0到1亿的数据测试性能，平均耗时6600ms左右
    return 0;
}